<?php

namespace app\api\controller;

use think\exception\ValidateException;

/**
 * 控制器基类
 */
abstract class BaseController
{
    /**
     * @param $validate
     * @param string $scene
     * @param array $params
     * @param bool $batch
     * @return void
     * 参数验证
     */
    protected function baseValidate($validate, string $scene, array $params = [], bool $batch = false)
    {
        $result = $validate->scene($scene)->batch($batch)->check($params);
        if(!$result) {
            throw new ValidateException($validate->getError());
        }
    }
}